package GUI;

import swimming.consumption;
import use.consumptionuse;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;


public class consume {
    private JPanel panel1;
    private JTextField TextField2;
    private JTextField textField1;
    private JButton 确定Button;
    private JTable table1;
    private JButton 会员卡充值Button;
    private JButton 查询修改会员信息Button;
    private JButton 更改系统密码Button;
    private JButton 新会员注册Button;
    private JButton 查询消费记录Button;
    private JButton 会员卡汇总记录Button;
    private JButton 使用会员卡Button;
    private JButton 消费记录报表Button;
    private DefaultTableModel table;
    private Object[][] data;
    private String[] total={"存款金额","结存金额","时间","电话","消费金额"};


    public static void iface(){
        JFrame frame = new JFrame("游泳馆会员管理系统");
        frame.setSize(500, 400);
        frame.setLocation(400, 200);

        consume t1 = new consume();
        frame.add(t1.panel1);

        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    public consume() {
        会员卡充值Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new recharge().iface();
            }
        });
        查询消费记录Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new consume().iface();
            }
        });
        查询修改会员信息Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new revise().iface();
            }
        });
        更改系统密码Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new password().iface();
            }
        });
        新会员注册Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new VIP().iface();
            }
        });
        会员卡汇总记录Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new totalVIP().iface();
            }
        });
        使用会员卡Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new usecard().iface();
            }
        });
        确定Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                consumptionuse cons = new consumptionuse();
                table.setRowCount(0);
                //ArrayList<Object> list=new ArrayList<>();
                //list.add(textField1.getText());
                //list.add(TextField2.getText());
                //for(Object o:list) {
                String a;
                a=TextField2.getText();
                    try {
                        List<consumption> list1 = cons.搜索(a);
                        for (consumption c : list1) {
                            String[] values = {c.getDepositamount(),c.getBalanceamount(),c.getTime(),c.getCardnum(),c.getConsumeamount()};
                            table.addRow(values);
                        }
                    } catch (SQLException ex) {
                        ex.printStackTrace();
                    }
                }
           // }
        });
        消费记录报表Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new baobiao().iface();
            }
        });
    }

    public static void main(String[] args) {
       iface();
    }

    private void createUIComponents() {
        // TODO: place custom component creation code here
        data=null;
        table=new DefaultTableModel(data,total);
        table1=new JTable(table);
    }
}
